﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Collections.ObjectModel;
using System.Windows.Data;
using System.Reflection;
using System.Text.RegularExpressions;
using FinPlusWCFConnData;
using FinPlusCommon;
using log = Logger.Logger;
using u = FinPlusUtility.Utility;

namespace FinPlusWPFControls
{
    public sealed class FinPlusContextMenu:FinPlusControl
    {
        public override string Id { get; set; }
        public override string[] States { get { return new string[] { }; } }
        public override string[] TestStates { get { return new string[] {  }; } }
        public override IFinPlusFunctions Model { get { return null; } }
        public override bool IsValid { get; set; }
        public override string ModelTest{get { return string.Empty; }}

        public ContextMenu Menu { get; private set; }

        private enum DockControls { FinPlusMenuItem, Exception }

        //construct
        public FinPlusContextMenu()
        {
            Menu = new ContextMenu();
            IsValid = true;
        }
   
        //common control interface 
        public override void Dock(object control, string dock)
        {
            try
            {
                switch (u.EnumTryParse<DockControls>(control.GetType().Name, DockControls.Exception))
                {
                    case DockControls.FinPlusMenuItem: AddMenuItem((FinPlusMenuItem)control); break;
                    case DockControls.Exception: throw new Exception(); 
                }
            }
            catch (Exception e)
            {
                IsValid = log.Log(Logger.Level.Error, Id, Config, e.Message, e);
            }
        }

        public override void Initialise()
        {

        }

        public override void CommandRouter(IFinPlusFunction func)
        {
            try
            {
                throw new NotImplementedException();
            }
            catch (Exception e)
            {
                IsValid = log.Log(Logger.Level.Warning, e.Message, e);
            }
        }

        public override void Dispose()
        {
            
        }

        //private
        private void AddMenuItem(FinPlusMenuItem menuItem)
        {
            Menu.Items.Add(menuItem.MenuItem);
        }
    }
}


























































































//Copyright2013<jnrton>AllRightsReserved 
//Contact j.nrton@finpus